# Makefile
# This file holds the make rules for the Telephony Engine test cases

# override DEBUG at compile time to enable full debug or remove it all
DEBUG :=

CXX := @CXX@ -Wall
SED := sed
DEFS :=
INCLUDES := -I@top_srcdir@
CFLAGS := -O0 @MODULE_CPPFLAGS@ @INLINE_FLAGS@
LDFLAGS:= @LDFLAGS@
YATELIBS:= -L../.. -lyate @LIBS@
MODFLAGS:= @MODULE_LDFLAGS@
MODSTRIP:= @MODULE_SYMBOLS@

MKDEPS  := ../../config.status
PROGS = randcall.yate msgdelay.yate
LIBS =
OBJS =

LOCALFLAGS =
LOCALLIBS =
COMPILE = $(CXX) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS)
LINK = $(CXX) $(LDFLAGS)
MODLINK = $(CXX) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS)
MODCOMP = $(COMPILE) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS)

prefix = @prefix@
exec_prefix = @exec_prefix@

# include optional local make rules
-include YateLocal.mak

.PHONY: all debug ddebug xdebug
all: $(LIBS) $(PROGS)

debug:
	$(MAKE) all DEBUG=-g3 MODSTRIP=

ddebug:
	$(MAKE) all DEBUG='-g3 -DDEBUG' MODSTRIP=

xdebug:
	$(MAKE) all DEBUG='-g3 -DXDEBUG' MODSTRIP=

.PHONY: strip
strip: all
	strip --strip-debug --discard-locals $(PROGS)

.PHONY: clean
clean:
	@-$(RM) $(PROGS) $(LIBS) $(OBJS) core 2>/dev/null

%.o: @srcdir@/%.cpp $(MKDEPS) @top_srcdir@/yateclass.h @top_srcdir@/yatengine.h
	$(COMPILE) -c $<

Makefile: @srcdir@/Makefile.in $(MKDEPS)
	cd ../.. && ./config.status

lib%.so: %.o
	$(LINK) -shared -o $@ $^

%.yate: @srcdir@/%.cpp $(MKDEPS) $(INCFILES)
	$(MODCOMP) -o $@ $(LOCALFLAGS) $< $(LOCALLIBS) $(YATELIBS)
